/**
 * 
 */
package modelscsw.restaurant.android.util;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import modelscsw.restaurant.android.places.Place;

/**
 * @author Leonardo E. Ibarra Becerra
 *
 */
public class SortPlaces {

	public static void sortByDistance(List<Place> places) {  
		 Collections.sort(places, new Comparator<Place>() {

			public int compare(Place place1, Place place2) {
				float dist1 = place1.getDistanceToOrigin();
				float dist2 = place2.getDistanceToOrigin();
				
				if (dist1 < dist2) return -1;
				if (dist1 > dist2) return 1;
				return 0;
			} 
			 
		 });
	}
}
